﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GameInstrument;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework;

namespace MainGame.GameInstrument
{
    public class BigExplosive : Weapon
    {
        public override Vector2 Position
        {
            get
            {
                return base.Position;
            }
            set
            {
                Vector2 d = value - this.Position;
                base.Position = value;
                foreach (var f in this.Fires)
                {
                    f.Position += d;
                }
            }
        }
        public BigExplosive(ContentManager content)
            : base(content)
        {
            Fire f1 = new Fire(content);
            Fire f2 = new Fire(content);
            Fire f3 = new Fire(content);
            Fire f4 = new Fire(content);
            Fire f5 = new Fire(content);
            Fire f6 = new Fire(content);
            Fire f7 = new Fire(content);
            Fire f8 = new Fire(content);
            Fire f9 = new Fire(content);
            Fire f10 = new Fire(content);
            Fire f11 = new Fire(content);
            Fire f12 = new Fire(content);
            Fire f13 = new Fire(content);
            Fire f14 = new Fire(content);
            Fire f15 = new Fire(content);
            Fire f16 = new Fire(content);
            Fire f17 = new Fire(content);
            Fire f18 = new Fire(content);
            Fire f19 = new Fire(content);

            f1.Position = new Vector2(0, 0);
            f2.Position = new Vector2(50, 0);
            f3.Position = new Vector2(0, 50);
            f4.Position = new Vector2(-50, 0);
            f5.Position = new Vector2(0, -50);
            f6.Position = new Vector2(0, 50);
            f7.Position = new Vector2(50, 0);
            f8.Position = new Vector2(00, -50);
            f9.Position = new Vector2(-50, 0);
            f10.Position = new Vector2(100, 0);
            f11.Position = new Vector2(0, 100);
            f12.Position = new Vector2(-100, 0);
            f13.Position = new Vector2(0, -100);
            f14.Position = new Vector2(150, 0);
            f15.Position = new Vector2(0, 150);
            f16.Position = new Vector2(-150, 0);
            f17.Position = new Vector2(0, -150);


            this.Fires.AddRange(new []{f1,f2,f3,f4,f5,f6,f7,f8,f9,f11,f12,f13,f14,f15,f16,f17,f18,f19 });
            this.Items.Add(f1.Items[0]);
        }

        protected override void UpdateEntitys(GameTime gameTime, object extraData)
        {
            base.UpdateEntitys(gameTime, extraData);
        }
        protected override void Paint(GameTime gameTime, Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch, object extraData)
        {
            if (Exploding)
            {
                foreach (var f in Fires)
                {
                    f.Draw(gameTime, spriteBatch, null);
                }
            }
        }
        public override bool CollisionWith(GameCharacter.Character other, bool pixelLevel)
        {
            foreach (var f in this.Fires) 
            {
                if (f.CollisionWith(other, pixelLevel))
                    return true;
            }
            return false;
        }
        public override void Explosive()
        {
            this.SoundExplosize.Play();
            Exploding = true;
        }
    }
}
